<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="org.windblog.core.OptionService,org.windblog.core.entity.Option,java.util.List"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Option manager</title>
<script type="text/javascript" src="/includes/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	   $("a").click(function() {
	    
	   });
	 });
</script>
</head>

<body>
<h1>Option manager</h1>
<hr />
<div id="msg" style="border:1px solid #005533;padding:0;background:#00dd55;width:20em;text-align:center;">
<%if(request.getAttribute("msg")!=null)out.print((String)request.getAttribute("msg")); %>
</div>
<div id="error" style="border:1px solid #990011;padding:0;background:#FF5555;width:20em;text-align:center;">
<%if(request.getAttribute("error")!=null)out.print((String)request.getAttribute("error")); %>
</div>
<form action="setoptions" method="post">
<table border="1" cellpadding="2">
	<caption>All options</caption>
	<thead>
	<tr>
		<td>name</td>
		<td>value</td>
		<td>action</td>
	</tr>
	</thead>
	<tbody>
	<%
		List<Option> options = OptionService.getAllOptions();
		for (Option option : options) {
	%>
	<tr>
		<td><%=option.getName()%></td>
		<td><input type="text" name="opt_<%=option.getName()%>"
			value="<%=option.getValue()%>" /></td>
		<td><a href="deleteoption?option_name=<%=option.getName() %>" >delete</a></td>
	</tr>
	<%
		}
	%>
	</tbody>
	<tfoot>
	<tr>
		<td colspan="3"><input type="submit" value="submit" /></td>
	</tr>
	</tfoot>
</table>
</form>

<br/>
<br/>
<form action="addoption" method="post">
<table border="1" cellpadding="2">
	<caption>Add option</caption>
	<tr>
		<td>name</td>
		<td>value</td>
	</tr>
	<tr>
		<td><input type="text" name="option_name" /></td>
		<td><input type="text" name="option_value" /></td>
	</tr>
	<tr>
		<td colspan="2"><input type="submit" value="Add" /></td>
	</tr>
</table>
</form>
</body>
</html>